package com.smartjobs.action;

import com.opensymphony.xwork2.ActionSupport;
import com.smartjobs.model.CreateCompanyProfileModel;

@SuppressWarnings("serial")
public class CompanyProfileAction extends ActionSupport {

	String companyName;
	String password;
	String emailID;
	String mobileNumber;

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmailID() {
		return emailID;
	}

	public void setEmailID(String emailID) {
		this.emailID = emailID;
	}

	public String getMobileNumber() {
		return mobileNumber;
	}

	public void setMobileNumber(String mobileNumber) {
		this.mobileNumber = mobileNumber;
	}

	public String execute() {
		return SUCCESS;
	}

	public String createProfile() {
		CreateCompanyProfileModel companyProfile = new CreateCompanyProfileModel();

		if (companyName.equals("")) {
			addActionError("Please enter company name.");
			return ERROR;
		} else {
			companyProfile.setCompanyName(companyName);
		}

		if (password.equals("")) {
			addActionError("Please enter password.");
			return ERROR;
		} else {
			companyProfile.setPassword(password);
		}

		if (emailID.equals("")) {
			addActionError("Please enter email address.");
			return ERROR;
		} else {
			companyProfile.setEmailID(emailID);
		}

		if (mobileNumber.equals("")) {
			addActionError("Please enter phone number.");
			return ERROR;
		} else {
			int mNo = Integer.parseInt(mobileNumber);
			companyProfile.setMobileNumber(mNo);
		}

		if (companyProfile.insertIntoDB(companyProfile))
			return SUCCESS;
		else
			return ERROR;

	}

}
